package com.lanyou.cook.util.curator;

import java.nio.charset.Charset;

import org.apache.curator.framework.recipes.queue.QueueSerializer;

public class StringSerializer implements QueueSerializer<String> {

	private final Charset charset;
	
	public StringSerializer(Charset charset) {
		super();
		this.charset = charset;
	}
	
	@Override
	public byte[] serialize(String item) {
		return item.getBytes(charset);
	}
	
	@Override
	public String deserialize(byte[] bytes) {
		return new String(bytes, charset);
	}
}
